package com.banyuan;

import com.banyuan.Utils.JDBCUtils;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class JianfanJDBC {
    public static void main(String[] args) {
        /*HashMap<String, String> map = getMap();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            try {
                JDBCUtils.executeUpdate("insert into jianfanbiao(jian,fan) values(?,?)",entry.getKey(),entry.getValue());

            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }*/


        ResultSet rs = null;
        try {
             rs = JDBCUtils.executeQuery("select * from jianfanbiao");
            while (rs.next()) {
                String jian = rs.getString("jian");
                String fan = rs.getString("fan");
                System.out.println(jian + "---" + fan);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            JDBCUtils.closeAllByRs(rs);
        }


    }









    public static HashMap<String,String> getMap()  {
        HashMap<String,String> map = new HashMap<>();
        List<String> stringList = null;
        try {
            stringList = FileUtils.readLines(new File("/Users/edy/Desktop/jf_map_utf8.txt"), "utf-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (String s : stringList) {
            String[] split = s.split(":");
            map.put(split[0],split[1]);
        }
        return map;
    }
}
